package com.conversationboard.api.model;

import static com.conversationboard.api.formatters.XmlWrapper.wrap;
import static com.conversationboard.api.formatters.XmlWrapper.wrapCDATA;

import com.conversationboard.api.formatters.XmlDateFormatter;
import com.conversationboard.formatter.DateFormatter;
import com.conversationboard.model.User;

public class UserXML {

	public static String getUserXML(User user, String password) {

		StringBuilder buffer = new StringBuilder();

		buffer.append("<UserInfo>");
		buffer.append(wrap("LoginId", user.getLoginId()));
		buffer.append(wrapCDATA("DisplayName", user.getFullDisplayName()));
		buffer.append(wrap("Locale", user.getLocale().getLanguage() + "-" + user.getLocale().getCountry()));
		buffer.append(wrap("CreationDate", XmlDateFormatter.format(user.getCreationDate())));
		buffer.append(wrap("CreationDateFormatted", DateFormatter.prettyPrint(user.getCreationDate(), user)));
		buffer.append(wrap("UserFor", DateFormatter.prettyPrintTime(user.getCreationDate(), user, true, false)));
		buffer.append(wrap("PostCount", user.getPostCount() + ""));
		buffer.append("</UserInfo>");

		return buffer.toString();
	}

}
